package org.gw.building.repositories;

import org.gw.building.model.Tyxxcjb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
 * Created by qwx89 on 2017/8/7.
 */
public interface TyxxcjbRepository extends CrudRepository<Tyxxcjb, String> {
  @Query("from Tyxxcjb t where ( ?1 is null or t.xh like ?1 or t.xm like ?1 ) and t.cjzbid = ?2 and t.gxzt.dm != 3 order by t.xh asc")
  Page<Tyxxcjb> findTyxx(String s, String cjzb, Pageable pageable);

  @Modifying
  @Query("delete from Tyxxcjb t where t.cjzbid = ?1")
  void delTyxxByCjzb(String id);

  List<Tyxxcjb> findByCjzbid(String cjzbid);
}
